//
//  KKMyHttp.m
//  DoMi
//
//  Created by 康凯 on 2016/11/10.
//  Copyright © 2016年 kk. All rights reserved.
//

#import "KKMyHttp.h"
#import "KKUserInfoM.h"
#import "KKUserInfoDetailM.h"
#import "KKJobItemM.h"
#import "KKAccountDetailM.h"
#import "KKCollectVideoM.h"
#import "KKCollectDocumentM.h"
#import "KKTiXianM.h"
#import "KKMyXuanShangM.h"
#import "KKMessageM.h"
#import "KKMyConsultM.h"
#import "KKFollowM.h"

@implementation KKMyHttp
#pragma mark 用户信息
+(void)getUserInfoSuccess:(void (^)(id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params=@{UID_KEY:UID,TOKEN_KEY:TOKEN};
    [KKBaseHttp Post:USER_INFO params:params success:^(id responseObject) {
        NSString *code=[responseObject objectForKey:@"code"];
        if([code isEqualToString:@"ok"]){
            KKUserInfoM *datas=[KKUserInfoM mj_objectWithKeyValues:responseObject];
            success(datas);
        }else{
            NSString *msg=[responseObject objectForKey:@"msg"];
            [self toast:msg];
        }
    } failure:^(NSError *error) {
        
    }];
}

#pragma mark 完善用户信息
+(void)getFinishInfoSuccess:(void (^)(id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params=@{UID_KEY:UID,TOKEN_KEY:TOKEN};
    [KKBaseHttp Post:USER_INFO_DETAIL params:params success:^(id responseObject) {
        NSString *code=[responseObject objectForKey:@"code"];
        if([code isEqualToString:@"ok"]){
            KKUserInfoDetailM *datas=[KKUserInfoDetailM mj_objectWithKeyValues:responseObject];
            success(datas);
        }else{
            NSString *msg=[responseObject objectForKey:@"msgmsg"];
            [self toast:msg];
        }
    } failure:^(NSError *error) {
        
    }];
}

#pragma mark 提交用户信息
+(void)updateUserInfo:(NSDictionary *)params success:(void (^)(id))success failure:(void (^)(NSError *))failure{
    [KKBaseHttp Post:UPDATE_USER_INFO params:params success:^(id responseObject) {
        NSString *code=[responseObject objectForKey:@"code"];
        if([code isEqualToString:@"ok"]){
            NSString *msg=[responseObject objectForKey:@"msg"];
            success(msg);
        }else{
            NSString *msg=[responseObject objectForKey:@"msg"];
            [self toast:msg];
        }
    } failure:^(NSError *error) {
        
    }];
}
#pragma mark 职位item
+(void)getJobItemSuccess:(void (^)(id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params=@{UID_KEY:UID,TOKEN_KEY:TOKEN};
    [KKBaseHttp Post:JOB_ITEM params:params success:^(id responseObject) {
        NSString *code=[responseObject objectForKey:@"code"];
        if([code isEqualToString:@"ok"]){
            NSArray *list=[responseObject objectForKey:@"list"];
            NSArray *datas=[KKJobItemM mj_objectArrayWithKeyValuesArray:list];
            success(datas);
        }else{
            NSString *msg=[responseObject objectForKey:@"msg"];
            [self toast:msg];
        }
    } failure:^(NSError *error) {
        
    }];
}
#pragma mark 行业item
+(void)getIndustryItemSuccess:(void (^)(id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params=@{UID_KEY:UID,TOKEN_KEY:TOKEN};
    [KKBaseHttp Post:INDUSTRY_ITEM params:params success:^(id responseObject) {
        NSString *code=[responseObject objectForKey:@"code"];
        if([code isEqualToString:@"ok"]){
            NSArray *list=[responseObject objectForKey:@"list"];
            NSArray *datas=[KKJobItemM mj_objectArrayWithKeyValuesArray:list];
            success(datas);
        }else{
            NSString *msg=[responseObject objectForKey:@"msg"];
            [self toast:msg];
        }
    } failure:^(NSError *error) {
        
    }];
}
#pragma mark 帐户当前余额
+(void)getCurrentPriceSuccess:(void (^)(id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params=@{UID_KEY:UID,TOKEN_KEY:TOKEN};
    [KKBaseHttp Post:ACCOUNT_BALANCE params:params success:^(id responseObject) {
        NSString *code=[responseObject objectForKey:@"code"];
        if([code isEqualToString:@"ok"]){
            NSString *datas=[responseObject objectForKey:@"balance"];
            success(datas);
        }else{
            NSString *msg=[responseObject objectForKey:@"msg"];
            [self toast:msg];
        }
    } failure:^(NSError *error) {
        
    }];
}
#pragma mark 帐户明细
+(void)getAccountDetail:(NSString *)page success:(void (^)(id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params=@{UID_KEY:UID,TOKEN_KEY:TOKEN,@"page":page};
    [KKBaseHttp Post:ACCOUNT_BALANCE_DETAIL params:params success:^(id responseObject) {
        NSString *code=[responseObject objectForKey:@"code"];
        if([code isEqualToString:@"ok"]){
            NSArray *list=[responseObject objectForKey:@"list"];
            NSArray *datas=[KKAccountDetailM mj_objectArrayWithKeyValuesArray:list];
            success(datas);
        }else{
            NSString *msg=[responseObject objectForKey:@"msg"];
            [self toast:msg];
        }
    } failure:^(NSError *error) {
        
    }];
}
#pragma mark 当前积分
+(void)getCurrentJiFenSuccess:(void (^)(id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params=@{UID_KEY:UID,TOKEN_KEY:TOKEN};
    [KKBaseHttp Post:JIFEN_BALANCE params:params success:^(id responseObject) {
        NSString *code=[responseObject objectForKey:@"code"];
        if([code isEqualToString:@"ok"]){
            NSString *datas=[responseObject objectForKey:@"balance"];
            success(datas);
        }else{
            NSString *msg=[responseObject objectForKey:@"msg"];
            [self toast:msg];
        }
    } failure:^(NSError *error) {
        
    }];
}
#pragma mark 积分明细
+(void)getJiFenDetail:(NSString *)page success:(void (^)(id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params=@{UID_KEY:UID,TOKEN_KEY:TOKEN,@"page":page};
    [KKBaseHttp Post:JIFEN_BALANCE_DETAIL params:params success:^(id responseObject) {
        NSString *code=[responseObject objectForKey:@"code"];
        if([code isEqualToString:@"ok"]){
            NSArray *list=[responseObject objectForKey:@"list"];
            NSArray *datas=[KKAccountDetailM mj_objectArrayWithKeyValuesArray:list];
            success(datas);
        }else{
            NSString *msg=[responseObject objectForKey:@"msg"];
            [self toast:msg];
        }
    } failure:^(NSError *error) {
        
    }];
}
#pragma mark 我收藏文章
+(void)getCollectDocument:(NSString *)page success:(void (^)(id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params=@{UID_KEY:UID,TOKEN_KEY:TOKEN,@"page":page};
    [KKBaseHttp Post:COLLECT_DOCUMENT params:params success:^(id responseObject) {
        NSString *code=[responseObject objectForKey:@"code"];
        if([code isEqualToString:@"ok"]){
            NSArray *list=[responseObject objectForKey:@"list"];
            NSArray *datas=[KKCollectDocumentM mj_objectArrayWithKeyValuesArray:list];
            success(datas);
        }else{
            NSString *msg=[responseObject objectForKey:@"msg"];
            [self toast:msg];
        }
    } failure:^(NSError *error) {
        
    }];
}
#pragma mark 我收藏视频
+(void)getCollectVideo:(NSString *)page success:(void (^)(id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params=@{UID_KEY:UID,TOKEN_KEY:TOKEN,@"page":page};
    [KKBaseHttp Post:COLLECT_VIDEO params:params success:^(id responseObject) {
        NSString *code=[responseObject objectForKey:@"code"];
        if([code isEqualToString:@"ok"]){
            NSArray *list=[responseObject objectForKey:@"list"];
            NSArray *datas=[KKCollectVideoM mj_objectArrayWithKeyValuesArray:list];
            success(datas);
        }else{
            NSString *msg=[responseObject objectForKey:@"msg"];
            [self toast:msg];
        }
    } failure:^(NSError *error) {
        
    }];
}

#pragma mark 删除收藏
+(void)deleteCollect:(NSString *)collectId success:(void (^)(id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params=@{UID_KEY:UID,TOKEN_KEY:TOKEN,@"collectid":collectId};
    [KKBaseHttp Post:DEL_COLLECT params:params success:^(id responseObject) {
        NSString *code=[responseObject objectForKey:@"code"];
        if([code isEqualToString:@"ok"]){
            NSString *msg=[responseObject objectForKey:@"msg"];
            success(msg);
        }else{
            NSString *msg=[responseObject objectForKey:@"msg"];
            [self toast:msg];
        }
    } failure:^(NSError *error) {
        
    }];
}

#pragma mark 提现信息
+(void)getTiXianInfoSuccess:(void (^)(id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params=@{UID_KEY:UID,TOKEN_KEY:TOKEN};
    [KKBaseHttp Post:TIXIAN_INFO params:params success:^(id responseObject) {
        NSString *code=[responseObject objectForKey:@"code"];
        if([code isEqualToString:@"ok"]){
            KKTiXianM *datas=[KKTiXianM mj_objectWithKeyValues:responseObject];
            success(datas);
        }else{
            NSString *msg=[responseObject objectForKey:@"msg"];
            [self toast:msg];
        }
    } failure:^(NSError *error) {
        
    }];
}
#pragma mark 提交提现
+(void)updateTiXianInfo:(NSDictionary *)params success:(void (^)(id))success failure:(void (^)(NSError *))failure{
    [KKBaseHttp Post:MY_TIXIAN params:params success:^(id responseObject) {
        NSString *code=[responseObject objectForKey:@"code"];
        if([code isEqualToString:@"ok"]){
            NSString *msg=[responseObject objectForKey:@"msg"];
            success(msg);
        }else{
            NSString *msg=[responseObject objectForKey:@"msg"];
            [self toast:msg];
        }
    } failure:^(NSError *error) {
        
    }];
}
#pragma mark 我上传文章
+(void)getUploadDocument:(NSString *)page success:(void (^)(id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params=@{UID_KEY:UID,TOKEN_KEY:TOKEN,@"page":page};
    [KKBaseHttp Post:UPLOAD_DOCUMENT params:params success:^(id responseObject) {
        NSString *code=[responseObject objectForKey:@"code"];
        if([code isEqualToString:@"ok"]){
            NSArray *list=[responseObject objectForKey:@"list"];
            NSArray *datas=[KKCollectDocumentM mj_objectArrayWithKeyValuesArray:list];
            success(datas);
        }else{
            NSString *msg=[responseObject objectForKey:@"msg"];
            [self toast:msg];
        }
    } failure:^(NSError *error) {
        
    }];
}
#pragma mark 删除我的上传
+(void)deleteDocument:(NSString *)documentId success:(void (^)(id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params=@{UID_KEY:UID,TOKEN_KEY:TOKEN,@"articleid":documentId};
    [KKBaseHttp Post:DEL_DOCUMENT params:params success:^(id responseObject) {
        NSString *code=[responseObject objectForKey:@"code"];
        if([code isEqualToString:@"ok"]){
            NSString *msg=[responseObject objectForKey:@"msg"];
            success(msg);
        }else{
            NSString *msg=[responseObject objectForKey:@"msg"];
            [self toast:msg];
        }
    } failure:^(NSError *error) {
        
    }];
}
#pragma mark 提交反馈
+(void)commitFeedBack:(NSDictionary *)params success:(void (^)(id))success failure:(void (^)(NSError *))failure{
    [KKBaseHttp Post:MY_FEEDBACK params:params success:^(id responseObject) {
        NSString *code=[responseObject objectForKey:@"code"];
        if([code isEqualToString:@"ok"]){
            NSString *msg=[responseObject objectForKey:@"msg"];
            success(msg);
        }else{
            NSString *msg=[responseObject objectForKey:@"msg"];
            [self toast:msg];
        }
    } failure:^(NSError *error) {
        
    }];
}
#pragma mark 我的悬赏
+(void)getMyXuanShang:(NSString *)type success:(void (^)(id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params=@{UID_KEY:UID,TOKEN_KEY:TOKEN,@"type":type};
    [KKBaseHttp Post:MY_XUANSHANG params:params success:^(id responseObject) {
        NSString *code=[responseObject objectForKey:@"code"];
        if([code isEqualToString:@"ok"]){
            NSArray *list=[responseObject objectForKey:@"list"];
            NSArray *datas=[KKMyXuanShangM mj_objectArrayWithKeyValuesArray:list];
            success(datas);
        }else{
            NSString *msg=[responseObject objectForKey:@"msg"];
            [self toast:msg];
        }
    } failure:^(NSError *error) {
        
    }];
}
#pragma mark 我的提问
+(void)getMyQuestion:(NSString *)type success:(void (^)(id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params=@{UID_KEY:UID,TOKEN_KEY:TOKEN,@"type":type};
    [KKBaseHttp Post:MY_QUESTION params:params success:^(id responseObject) {
        NSString *code=[responseObject objectForKey:@"code"];
        if([code isEqualToString:@"ok"]){
            NSArray *list=[responseObject objectForKey:@"list"];
            NSArray *datas=[KKMyXuanShangM mj_objectArrayWithKeyValuesArray:list];
            success(datas);
        }else{
            NSString *msg=[responseObject objectForKey:@"msg"];
            [self toast:msg];
        }
    } failure:^(NSError *error) {
        
    }];
}
#pragma mark 我的草稿箱
+(void)getDraftBoxList:(NSString *)page success:(void (^)(id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params=@{UID_KEY:UID,TOKEN_KEY:TOKEN,@"page":page};
    [KKBaseHttp Post:MY_DRAFTBOX params:params success:^(id responseObject) {
        NSString *code=[responseObject objectForKey:@"code"];
        if([code isEqualToString:@"ok"]){
            NSArray *list=[responseObject objectForKey:@"list"];
            NSArray *datas=[KKCollectDocumentM mj_objectArrayWithKeyValuesArray:list];
            success(datas);
        }else{
            NSString *msg=[responseObject objectForKey:@"msg"];
            [self toast:msg];
        }
    } failure:^(NSError *error) {
        
    }];
}
#pragma mark 删除草稿箱
+(void)delDraftBox:(NSString *)articleId success:(void (^)(id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params=@{UID_KEY:UID,TOKEN_KEY:TOKEN,@"articleid":articleId};
    [KKBaseHttp Post:DEL_DRAFTBOX params:params success:^(id responseObject) {
        NSString *code=[responseObject objectForKey:@"code"];
        if([code isEqualToString:@"ok"]){
            NSString *msg=[responseObject objectForKey:@"msg"];
            success(msg);
        }else{
            NSString *msg=[responseObject objectForKey:@"msg"];
            [self toast:msg];
        }
    } failure:^(NSError *error) {
        
    }];
}
#pragma mark 我的消息
+(void)getMyMsg:(NSString *)type success:(void (^)(id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params=@{UID_KEY:UID,TOKEN_KEY:TOKEN,@"type":type};
    [KKBaseHttp Post:MY_MESSAGE params:params success:^(id responseObject) {
        NSString *code=[responseObject objectForKey:@"code"];
        if([code isEqualToString:@"ok"]){
            NSArray *list=[responseObject objectForKey:@"list"];
            NSArray *datas=[KKMessageM mj_objectArrayWithKeyValuesArray:list];
            success(datas);
        }else{
            NSString *msg=[responseObject objectForKey:@"msg"];
            [self toast:msg];
        }
    } failure:^(NSError *error) {
        
    }];
}
#pragma mark 我的咨询
+(void)getMyAdviceList:(NSString *)page success:(void (^)(id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params=@{UID_KEY:UID,TOKEN_KEY:TOKEN,@"page":page};
    [KKBaseHttp Post:MY_ADVICE params:params success:^(id responseObject) {
        NSString *code=[responseObject objectForKey:@"code"];
        if([code isEqualToString:@"ok"]){
            NSArray *list=[responseObject objectForKey:@"list"];
            NSArray *datas=[KKMyConsultM mj_objectArrayWithKeyValuesArray:list];
            success(datas);
        }else{
            NSString *msg=[responseObject objectForKey:@"msg"];
            [self toast:msg];
        }
    } failure:^(NSError *error) {
        
    }];
}
#pragma mark 我的咨询待回复
+(void)getAdviceWaitAnswer:(NSString *)page success:(void (^)(id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params=@{UID_KEY:UID,TOKEN_KEY:TOKEN,@"page":page};
    [KKBaseHttp Post:MY_ADVICE_WAIT_ANSWER params:params success:^(id responseObject) {
        NSString *code=[responseObject objectForKey:@"code"];
        if([code isEqualToString:@"ok"]){
            NSArray *list=[responseObject objectForKey:@"list"];
            NSArray *datas=[KKMyConsultM mj_objectArrayWithKeyValuesArray:list];
            success(datas);
        }else{
            NSString *msg=[responseObject objectForKey:@"msg"];
            [self toast:msg];
        }
    } failure:^(NSError *error) {
        
    }];
}
#pragma mark 我购买的视频
+(void)getMyBuyList:(NSString *)page success:(void (^)(id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params=@{UID_KEY:UID,TOKEN_KEY:TOKEN,@"page":page};
    [KKBaseHttp Post:MY_BUY_VIDEO params:params success:^(id responseObject) {
        NSString *code=[responseObject objectForKey:@"code"];
        if([code isEqualToString:@"ok"]){
            NSArray *list=[responseObject objectForKey:@"list"];
            NSArray *datas=[KKCollectVideoM mj_objectArrayWithKeyValuesArray:list];
            success(datas);
        }else{
            NSString *msg=[responseObject objectForKey:@"msg"];
            [self toast:msg];
        }
    } failure:^(NSError *error) {
        failure(error);
    }];
}
#pragma mark 读我的消息
+(void)readMessage:(NSString *)msgId success:(void (^)(id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params=@{UID_KEY:UID,TOKEN_KEY:TOKEN,@"nid":msgId};
    [KKBaseHttp Post:MY_MESSAGE_READ params:params success:^(id responseObject) {
        NSString *code=[responseObject objectForKey:@"code"];
        if([code isEqualToString:@"ok"]){
            NSString *msg=[responseObject objectForKey:@"msg"];
            success(msg);
        }else{
            NSString *msg=[responseObject objectForKey:@"msg"];
            [self toast:msg];
        }
    } failure:^(NSError *error) {
        
    }];
}
#pragma mark 我的粉丝
+(void)getFanList:(NSString *)userId success:(void (^)(id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params=@{UID_KEY:userId};
    [KKBaseHttp Post:MY_FANS params:params success:^(id responseObject) {
        NSString *code=[responseObject objectForKey:@"code"];
        if([code isEqualToString:@"ok"]){
            NSArray *list=[responseObject objectForKey:@"list"];
            NSArray *datas=[KKFollowM mj_objectArrayWithKeyValuesArray:list];
            success(datas);
        }else{
            NSString *msg=[responseObject objectForKey:@"msgmsg"];
            [self toast:msg];
        }
    } failure:^(NSError *error) {
        
    }];
}

#pragma mark 我的关注
+(void)getFollowList:(NSString *)userId success:(void (^)(id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params=@{UID_KEY:userId};
    [KKBaseHttp Post:MY_FOLLOWS params:params success:^(id responseObject) {
        NSString *code=[responseObject objectForKey:@"code"];
        if([code isEqualToString:@"ok"]){
            NSArray *list=[responseObject objectForKey:@"list"];
            NSArray *datas=[KKFollowM mj_objectArrayWithKeyValuesArray:list];
            success(datas);
        }else{
            NSString *msg=[responseObject objectForKey:@"msgmsg"];
            [self toast:msg];
        }
    } failure:^(NSError *error) {
        
    }];
}
#pragma mark 关注
+(void)addFollow:(NSString *)followId success:(void (^)(id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params=@{UID_KEY:UID,TOKEN_KEY:TOKEN,@"attentionuid":followId};
    [KKBaseHttp Post:ADD_FOLLOW params:params success:^(id responseObject) {
        NSString *code=[responseObject objectForKey:@"code"];
        if([code isEqualToString:@"ok"]){
            NSString *msg=[responseObject objectForKey:@"msg"];
            success(msg);
        }else{
            NSString *msg=[responseObject objectForKey:@"msg"];
            [self toast:msg];
        }
    } failure:^(NSError *error) {
        
    }];
}
#pragma mark 取消关注
+(void)cancelFollow:(NSString *)followId success:(void (^)(id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params=@{UID_KEY:UID,TOKEN_KEY:TOKEN,@"attentionuid":followId};
    [KKBaseHttp Post:CANCEL_FOLLOW params:params success:^(id responseObject) {
        NSString *code=[responseObject objectForKey:@"code"];
        if([code isEqualToString:@"ok"]){
            NSString *msg=[responseObject objectForKey:@"msg"];
            success(msg);
        }else{
            NSString *msg=[responseObject objectForKey:@"msg"];
            [self toast:msg];
        }
    } failure:^(NSError *error) {
        
    }];
}
#pragma mark 删除我的咨询
+(void)delConsult:(NSString *)consultId success:(void (^)(id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params=@{UID_KEY:UID,TOKEN_KEY:TOKEN,@"consultid":consultId};
    [KKBaseHttp Post:DEL_CONSULT params:params success:^(id responseObject) {
        NSString *code=[responseObject objectForKey:@"code"];
        if([code isEqualToString:@"ok"]){
            NSString *msg=[responseObject objectForKey:@"msg"];
            success(msg);
        }else{
            NSString *msg=[responseObject objectForKey:@"msg"];
            [self toast:msg];
        }
    } failure:^(NSError *error) {
        
    }];
}
#pragma mark 用户查询
+(void)userCheck:(void (^)(id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params=@{UID_KEY:UID,TOKEN_KEY:TOKEN};
    [KKBaseHttp Post:USER_CHECK params:params success:^(id responseObject) {
        NSString *code=[responseObject objectForKey:@"code"];
        if([code isEqualToString:@"ok"]){
            NSString *msg=[responseObject objectForKey:@"msg"];
            success(msg);
        }else{
            NSString *msg=[responseObject objectForKey:@"msg"];
            [self toast:msg];
        }
    } failure:^(NSError *error) {
        
    }];
}
@end
